﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Site1.Master" AutoEventWireup="true" CodeBehind="Orders.aspx.cs" Inherits="gamexpert.admin.Orders" Theme="Admin" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h2>Orders</h2>
   
<div class="content">
    <asp:MultiView ID="MultiView1" runat="server">
        <asp:View ID="View1" runat="server">
        <p>List of orders from all users. Please click select link to view details product items list in each order.</p>
         <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
        BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
        DataKeyNames="id" DataSourceID="SqlDataSource1" ForeColor="Black" 
        GridLines="Vertical" onselectedindexchanged="GridView1_SelectedIndexChanged">
        <RowStyle BackColor="#F7F7DE" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowSelectButton="True" />
            <asp:BoundField DataField="id" HeaderText="Order ID" InsertVisible="False" 
                ReadOnly="True" SortExpression="id" />
            <asp:BoundField DataField="total" HeaderText="Total(S$)" 
                SortExpression="total" />
            <asp:BoundField DataField="sfirstname" HeaderText="First Name(shipping)" 
                SortExpression="sfirstname" />
            <asp:BoundField DataField="slastname" HeaderText="Last Name(shipping)" 
                SortExpression="slastname" />
            <asp:BoundField DataField="semail" HeaderText="Email(shipping)" 
                SortExpression="semail" />
            <asp:BoundField DataField="saddress" HeaderText="Address(shipping)" 
                SortExpression="saddress" />
            <asp:BoundField DataField="scity" HeaderText="City(shipping)" 
                SortExpression="scity" />
            <asp:BoundField DataField="sstate" HeaderText="State(shipping)" 
                SortExpression="sstate" />
            <asp:BoundField DataField="scountry" HeaderText="Country(shipping)" 
                SortExpression="scountry" />
            <asp:BoundField DataField="szip" HeaderText="Postal Code(shipping)" 
                SortExpression="szip" />
            <asp:BoundField DataField="sphone" HeaderText="Phone(shipping)" 
                SortExpression="sphone" />
            <asp:BoundField DataField="bfirstname" HeaderText="First Name(billing)" 
                SortExpression="bfirstname" />
            <asp:BoundField DataField="blastname" HeaderText="Last Name(billing)" 
                SortExpression="blastname" />
            <asp:BoundField DataField="bemail" HeaderText="Email(billing)" 
                SortExpression="bemail" />
            <asp:BoundField DataField="baddress" HeaderText="Address(billing)" 
                SortExpression="baddress" />
            <asp:BoundField DataField="bcity" HeaderText="City(billing)" 
                SortExpression="bcity" />
            <asp:BoundField DataField="bstate" HeaderText="State(billing)" 
                SortExpression="bstate" />
            <asp:BoundField DataField="bzip" HeaderText="Postal Code(billing)" 
                SortExpression="bzip" />
            <asp:BoundField DataField="bcountry" HeaderText="Country(billing)" 
                SortExpression="bcountry" />
            <asp:BoundField DataField="orderdate" HeaderText="Order date" 
                SortExpression="orderdate" />
            <asp:BoundField DataField="bphone" HeaderText="Phone(billing)" 
                SortExpression="bphone" />
        </Columns>
        <FooterStyle BackColor="#CCCC99" />
        <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:gamexpertConnectionString %>" 
        DeleteCommand="DELETE FROM [my_order] WHERE [id] = @original_id" 
        InsertCommand="INSERT INTO [my_order] ([sfirstname], [slastname], [semail], [saddress], [scity], [sstate], [scountry], [szip], [bfirstname], [blastname], [sphone], [bemail], [baddress], [bcity], [bstate], [bzip], [bcountry], [orderdate], [total], [tax], [bphone]) VALUES (@sfirstname, @slastname, @semail, @saddress, @scity, @sstate, @scountry, @szip, @bfirstname, @blastname, @sphone, @bemail, @baddress, @bcity, @bstate, @bzip, @bcountry, @orderdate, @total, @tax, @bphone)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT [id], [sfirstname], [slastname], [semail], [saddress], [scity], [sstate], [scountry], [szip], [bfirstname], [blastname], [sphone], [bemail], [baddress], [bcity], [bstate], [bzip], [bcountry], [orderdate], [total], [tax], [bphone] FROM [my_order]" 
        
        UpdateCommand="UPDATE [my_order] SET [sfirstname] = @sfirstname, [slastname] = @slastname, [semail] = @semail, [saddress] = @saddress, [scity] = @scity, [sstate] = @sstate, [scountry] = @scountry, [szip] = @szip, [bfirstname] = @bfirstname, [blastname] = @blastname, [sphone] = @sphone, [bemail] = @bemail, [baddress] = @baddress, [bcity] = @bcity, [bstate] = @bstate, [bzip] = @bzip, [bcountry] = @bcountry, [orderdate] = @orderdate, [total] = @total, [tax] = @tax, [bphone] = @bphone WHERE [id] = @original_id">
        <DeleteParameters>
            <asp:Parameter Name="original_id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="sfirstname" Type="String" />
            <asp:Parameter Name="slastname" Type="String" />
            <asp:Parameter Name="semail" Type="String" />
            <asp:Parameter Name="saddress" Type="String" />
            <asp:Parameter Name="scity" Type="String" />
            <asp:Parameter Name="sstate" Type="String" />
            <asp:Parameter Name="scountry" Type="String" />
            <asp:Parameter Name="szip" Type="String" />
            <asp:Parameter Name="bfirstname" Type="String" />
            <asp:Parameter Name="blastname" Type="String" />
            <asp:Parameter Name="sphone" Type="String" />
            <asp:Parameter Name="bemail" Type="String" />
            <asp:Parameter Name="baddress" Type="String" />
            <asp:Parameter Name="bcity" Type="String" />
            <asp:Parameter Name="bstate" Type="String" />
            <asp:Parameter Name="bzip" Type="String" />
            <asp:Parameter Name="bcountry" Type="String" />
            <asp:Parameter Name="orderdate" Type="DateTime" />
            <asp:Parameter Name="total" Type="Decimal" />
            <asp:Parameter Name="tax" Type="Single" />
            <asp:Parameter Name="bphone" Type="String" />
            <asp:Parameter Name="original_id" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="sfirstname" Type="String" />
            <asp:Parameter Name="slastname" Type="String" />
            <asp:Parameter Name="semail" Type="String" />
            <asp:Parameter Name="saddress" Type="String" />
            <asp:Parameter Name="scity" Type="String" />
            <asp:Parameter Name="sstate" Type="String" />
            <asp:Parameter Name="scountry" Type="String" />
            <asp:Parameter Name="szip" Type="String" />
            <asp:Parameter Name="bfirstname" Type="String" />
            <asp:Parameter Name="blastname" Type="String" />
            <asp:Parameter Name="sphone" Type="String" />
            <asp:Parameter Name="bemail" Type="String" />
            <asp:Parameter Name="baddress" Type="String" />
            <asp:Parameter Name="bcity" Type="String" />
            <asp:Parameter Name="bstate" Type="String" />
            <asp:Parameter Name="bzip" Type="String" />
            <asp:Parameter Name="bcountry" Type="String" />
            <asp:Parameter Name="orderdate" Type="DateTime" />
            <asp:Parameter Name="total" Type="Decimal" />
            <asp:Parameter Name="tax" Type="Single" />
            <asp:Parameter Name="bphone" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
        </asp:View>
        <asp:View ID="View2" runat="server">
            <p>List of products in the selected order.</p>
            <asp:GridView ID="GridView2" runat="server" AllowPaging="True" 
                AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
                BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
                DataKeyNames="id" DataSourceID="SqlDataSource2" ForeColor="Black" 
                GridLines="Vertical">
                <RowStyle BackColor="#F7F7DE" />
                <Columns>
                    <asp:BoundField DataField="orderid" HeaderText="orderid" 
                        SortExpression="orderid" />
                    <asp:BoundField DataField="product_title" HeaderText="product_title" 
                        SortExpression="product_title" />
                    <asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
                    <asp:BoundField DataField="shippingcost" HeaderText="shippingcost" 
                        SortExpression="shippingcost" />
                    <asp:BoundField DataField="qty" HeaderText="qty" SortExpression="qty" />
                    <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                        ReadOnly="True" SortExpression="id" />
                </Columns>
                <FooterStyle BackColor="#CCCC99" />
                <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                ConnectionString="<%$ ConnectionStrings:gamexpertConnectionString %>" 
                DeleteCommand="DELETE FROM [my_orderproduct] WHERE [id] = @id" 
                InsertCommand="INSERT INTO [my_orderproduct] ([orderid], [product_title], [price], [shippingcost], [qty]) VALUES (@orderid, @product_title, @price, @shippingcost, @qty)" 
                SelectCommand="SELECT [orderid], [product_title], [price], [shippingcost], [qty], [id] FROM [my_orderproduct] WHERE ([orderid] = @orderid)" 
                UpdateCommand="UPDATE [my_orderproduct] SET [orderid] = @orderid, [product_title] = @product_title, [price] = @price, [shippingcost] = @shippingcost, [qty] = @qty WHERE [id] = @id">
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView1" Name="orderid" 
                        PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
                <DeleteParameters>
                    <asp:Parameter Name="id" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="orderid" Type="Int32" />
                    <asp:Parameter Name="product_title" Type="String" />
                    <asp:Parameter Name="price" Type="Decimal" />
                    <asp:Parameter Name="shippingcost" Type="Decimal" />
                    <asp:Parameter Name="qty" Type="Int32" />
                    <asp:Parameter Name="id" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="orderid" Type="Int32" />
                    <asp:Parameter Name="product_title" Type="String" />
                    <asp:Parameter Name="price" Type="Decimal" />
                    <asp:Parameter Name="shippingcost" Type="Decimal" />
                    <asp:Parameter Name="qty" Type="Int32" />
                </InsertParameters>
            </asp:SqlDataSource>
            <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Back</asp:LinkButton>
            <br />
        </asp:View>
    </asp:MultiView>


    
</div>
</asp:Content>
